package com.yxhl.zoume.core.tripsmgmt.ui.fragment.tripsdetail;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.afollestad.materialdialogs.MaterialDialog;
import com.yxhl.protobuf.BizOrder;
import com.yxhl.protobuf.BizOrderResponse;
import com.yxhl.protobuf.JudgeEntry;
import com.yxhl.protobuf.OrderBizType;
import com.yxhl.protobuf.OrderPayStatus;
import com.yxhl.protobuf.OrderRideStatus;
import com.yxhl.zoume.R;
import com.yxhl.zoume.UIConstants;
import com.yxhl.zoume.common.ui.custom.CheckBoxLayout;
import com.yxhl.zoume.common.ui.fragment.BaseFragment;
import com.yxhl.zoume.core.car.fragment.common.CancelCarOrderFeedbackFragment;
import com.yxhl.zoume.core.func.appraisal.model.AppraisalDriverInfo;
import com.yxhl.zoume.core.func.appraisal.model.CommentOnDriverEvent;
import com.yxhl.zoume.core.func.appraisal.ui.activity.AppraisalConfirmActivity;
import com.yxhl.zoume.core.tripsmgmt.info.CommentEntrance;
import com.yxhl.zoume.core.tripsmgmt.presenter.detail.DetailTripContainerPresenter;
import com.yxhl.zoume.core.tripsmgmt.ui.activity.TripDetailContainerActivity;
import com.yxhl.zoume.core.tripsmgmt.ui.event.CancelTripOrderEvent;
import com.yxhl.zoume.core.tripsmgmt.view.detail.DetailOrderView;
import com.yxhl.zoume.di.component.trip.DaggerTripComponent;
import com.yxhl.zoume.di.module.ActivityModule;
import com.yxhl.zoume.di.module.trip.TripModule;
import com.yxhl.zoume.utils.LOG;
import com.yxhl.zoume.utils.PromptUtils;
import com.yxhl.zoume.utils.StringUtils;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.functions.Action1;

import static com.yxhl.protobuf.OrderPayStatus.PAY_CANCEL;

/**
 * created by sugarya 16/08/18
 */
public class OfficialCarTripDetailFragment extends BaseFragment implements DetailOrderView {

    private static final String TAG = "OfficialCarDetailFrag";
    private static final String CALL_CAR_FOR_OTHER = "IS_CCFO"; //替他人叫车
    private static final String OTHER_MOBILE = "OM"; // 他人手机号
    //头部
    @BindView(R.id.rl_include_trip_detail_station_info)
    RelativeLayout mStationInfoRl;
    @BindView(R.id.iv_include_trip_detail_station_info_icon)
    ImageView mStationInfoIconIv;
    @BindView(R.id.tv_include_trip_detail_station_info_start)
    TextView mStationInfoStartTv;
    @BindView(R.id.tv_include_trip_detail_station_info_clock)
    TextView mStationInfoClockTv;
    @BindView(R.id.tv_include_trip_detail_station_info_date)
    TextView mStationInfoDateTv;
    @BindView(R.id.tv_include_trip_detail_station_info_destination)
    TextView mStationInfoDestinationTv;
    //乘客信息栏
    @BindView(R.id.tv_official_car_trip_first_row_content)
    TextView mFirstRowContentTv;
    @BindView(R.id.tv_official_car_trip_second_row_content)
    TextView mSecondRowContentTv;
    @BindView(R.id.iv_official_car_trip_info_map)
    ImageView mTripInfoMapIv;
    //订单信息栏
    @BindView(R.id.tv_include_trip_detail_order_id_content)
    TextView mOrderIdContentTv;
    /**
     * 订单状态
     */
    @BindView(R.id.tv_include_trip_detail_order_status_content)
    TextView mOrderStatusContentTv;
    /**
     * 创建订单
     */
    @BindView(R.id.tv_include_trip_detail_order_create_time_content)
    TextView mOrderCreateTimeContentTv;
    /**
     * 上车
     */
    @BindView(R.id.tv_include_trip_detail_get_in_content)
    TextView mGetInContentTv;
    /**
     * 下车
     */
    @BindView(R.id.tv_include_trip_detail_get_off_content)
    TextView mGetOffContentTv;
    //评价司机栏
    @BindView(R.id.rl_include_trip_detail_judge_info)
    RelativeLayout mJudgeInfoRl;
    @BindView(R.id.cbl_include_trip_detail_judge)
    CheckBoxLayout mJudgeCbl;
    @BindView(R.id.tv_include_trip_detail_judge)
    TextView mJudgeTv;
    //底部信息栏
    @BindView(R.id.frame_official_car_bottom_container)
    FrameLayout bottomContainerFrame;
    @BindView(R.id.ll_official_car_bottom_cancel_order_bar)
    LinearLayout mCancelOrderBarLl;
    //arguments
    @BindView(R.id.tv_official_car_bottom_cancel_order)
    TextView bottomCancelOrderTv;
    @BindView(R.id.ll_server_comment)
    LinearLayout mLlServerComment;  //服务评价
    @Inject
    DetailTripContainerPresenter mDetailTripContainerPresenter;
    private BizOrder mBizOrder;
    private MaterialDialog mMaterialDialog;


    public OfficialCarTripDetailFragment() {
        // Required empty public constructor
    }

    public static OfficialCarTripDetailFragment newInstance(BizOrder bizOrder) {

        Bundle args = new Bundle();
        args.putSerializable(UIConstants.TripContainer.ARGUMENT_KEY_OFFICIAL_CAR_TRIP_DETAIL_ORDER, bizOrder);
        OfficialCarTripDetailFragment fragment = new OfficialCarTripDetailFragment();
        fragment.setArguments(args);
        return fragment;
    }

    private void parseArguments() {
        Bundle arguments = getArguments();
        if (arguments != null) {
            mBizOrder = (BizOrder) arguments.getSerializable(UIConstants.TripContainer.ARGUMENT_KEY_OFFICIAL_CAR_TRIP_DETAIL_ORDER);
        }
    }

    private void onRxBusEvent() {
        //取消订单
        getSubscription().add(toSubscription(CancelTripOrderEvent.class,
                new Action1<CancelTripOrderEvent>() {
                    @Override
                    public void call(CancelTripOrderEvent cancelTripOrderEvent) {
                        if (mBizOrder != null) {
                            OrderRideStatus rideStatus = mBizOrder.getRideStatus();
                            switch (rideStatus) {
                                case UN_SEND:
                                    mActivity.finish();
                                    break;
                                default:
                                    String orderSerial = mBizOrder.getOrderSerial();
                                    mDetailTripContainerPresenter.getDetailTripOrder(orderSerial);
                            }
                        }
                    }
                },
                new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        onRxBusEvent();
                    }
                }
        ));
        //评价司机
        getSubscription().add(toSubscription(
                CommentOnDriverEvent.class,
                new Action1<CommentOnDriverEvent>() {
                    @Override
                    public void call(CommentOnDriverEvent commentOnDriverEvent) {
                        int point = commentOnDriverEvent.getPoint();
                        CommentEntrance commentEntrance = commentOnDriverEvent.getCommentEntrance();

//                        switch (commentEntrance) {
//                            case OFFICIAL_CAR:
                        mJudgeTv.setVisibility(View.INVISIBLE);
                        mJudgeInfoRl.setVisibility(View.VISIBLE);
                        showJudePoint(point);
//                                break;
//                        }
                    }
                },
                new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        LOG.e(TAG, "throwable=" + throwable.toString());
                        onRxBusEvent();
                    }
                }
        ));


    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        parseArguments();
        onRxBusEvent();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        ViewCompat.setTransitionName(mStationInfoRl, UIConstants.TripContainer.TRIP_DETAIL_SHARE_ELEMENT);
        mDetailTripContainerPresenter.attachView(this);
        initializeShow(mBizOrder);
        bindData(mBizOrder);
        ButterKnife.bind(this, view != null ? view : null);
        return view;
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mDetailTripContainerPresenter.getDetailTripOrder(mBizOrder.getOrderSerial());
    }

    @Override
    public void onStart() {
        super.onStart();
        mLlServerComment.setClickable(false);
        setCommentItemEnable();

    }

    private void setCommentItemEnable() {
        if (View.VISIBLE == mJudgeCbl.getVisibility()) {
            mLlServerComment.setClickable(true);
        }
    }


    /**
     * 取消订单
     */
    @OnClick(R.id.ll_official_car_bottom_cancel_order_bar)
    void onCancelOrderClick() {

//        mMaterialDialog = DialogUtils.getDialog(
//                mActivity,
//                getString(R.string.special_car_dialog_cancel_schedule_message),
//                getString(R.string.special_car_dialog_confirm),
//                getString(R.string.special_car_dialog_cancel),
//                new MaterialDialog.SingleButtonCallback() {
//                    @Override
//                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
        ((TripDetailContainerActivity) mActivity).replaceFragment(
                R.id.frame_activity_trip_detail_container,
                CancelCarOrderFeedbackFragment.newInstance(mBizOrder.getOrderSerial()),
                true
        );
//                    }
//                },
//                new MaterialDialog.SingleButtonCallback() {
//                    @Override
//                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
//                        dialog.dismiss();
//                    }
//                }
//        );
//        mMaterialDialog.show();
    }

    /**
     * 进入地图
     */
    @OnClick(R.id.iv_official_car_trip_info_map)
    void onTripInfoMapClick() {
        getAppComponent().navigator().navigateToOfficialCarScheduleActivity(mActivity, mBizOrder.getOrderSerial());
    }

    /**
     * 去评价
     */
    @OnClick(R.id.tv_include_trip_detail_judge)
    void onJudgeDriverClick() {
        AppraisalDriverInfo driverInfo = getAppraisalDriverInfo();
        getAppComponent().navigator().navigateToAppraisal(mActivity, driverInfo);
    }

    private AppraisalDriverInfo getAppraisalDriverInfo() {
        AppraisalDriverInfo driverInfo = new AppraisalDriverInfo();
        driverInfo.setOrderId(mBizOrder.getOrderSerial())
                .setDriverName(mBizOrder.getDriverName())
                .setHistoryScore(Double.valueOf((TextUtils.isEmpty(mBizOrder.getAvgDriverPoint())) ? "4" : mBizOrder.getAvgDriverPoint()))
                .setPlateNumber(mBizOrder.getVehicleNo());
        return driverInfo;
    }

    /**
     * 跳转到评价点击
     */
    @OnClick(R.id.ll_server_comment)
    public void onClick() {
        navigateToAppraisalResult(mActivity, getAppraisalDriverInfo());
    }

    /**
     * 跳转到评价结果页面
     *
     * @param activity
     * @param driverInfo
     */
    private void navigateToAppraisalResult(Activity activity, AppraisalDriverInfo driverInfo) {
        Intent intent = AppraisalConfirmActivity.getCallingIntent(activity, driverInfo);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.right_enter, R.anim.left_out);

    }


    /**
     * 初始化UI展示
     *
     * @param bizOrder
     */
    private void initializeShow(BizOrder bizOrder) {
        OrderPayStatus payStatus = bizOrder.getPayStatus();
        OrderBizType bizType = bizOrder.getBizType();

        //改变顶部信息
        exchangeStationInfoIcon(bizType);
        //地图图标样式
        exchangeTripMapStyle(payStatus);

        //司机评价栏
        exchangeJudgeDriverStyle(payStatus);

        //改变底部信息栏信息
        exchangeBottomBarStyle(bizOrder);
    }

    private void bindData(BizOrder bizOrder) {
        OrderPayStatus payStatus = bizOrder.getPayStatus();
        OrderRideStatus rideStatus = bizOrder.getRideStatus();
        //头部站点信息
        setStartStation(bizOrder.getStart());
        setDestination(bizOrder.getDestination());
        setStartTimeAndData(bizOrder.getGmtDepart());

        //公务车信息
        String driverInfo = bizOrder.getVehicleNo() + StringUtils.getCalledName(bizOrder.getDriverName());
        setTripFirstRowContent(driverInfo, payStatus);
        String satus = bizOrder.getAttributes().get(CALL_CAR_FOR_OTHER);
        if (satus.equals("false")) {
            setTripSecondRowContent(bizOrder.getMobile());     //乘车人
        } else {
            setTripSecondRowContent(bizOrder.getAttributes().get(OTHER_MOBILE));
        }


        //订单状态信息
        setOrderId(bizOrder.getOrderSerial());
        setOrderStatus(payStatus, rideStatus);
        setGmtCreate(bizOrder.getGmtCreate());
        //上车时间
        setGetInTime(bizOrder.getGmtStart(), rideStatus, payStatus);
        //下车时间
        setGetOffTime(bizOrder.getGmtEnd());

        //评论
        JudgeEntry judgeEntry = bizOrder.getJudge();
        setDriverJudge(judgeEntry);
    }

    /**
     * 改变行程详情类型图标
     *
     * @param bizType
     */
    private void exchangeStationInfoIcon(OrderBizType bizType) {
        switch (bizType) {
            case OFFICIAL_BUS_WAY:
                mStationInfoIconIv.setImageResource(R.drawable.ic_dancheng_gongwu);
                break;
            case OFFICIAL_BUS_TIME:
                mStationInfoIconIv.setImageResource(R.drawable.ic_fenshi_gongwu);
                break;
        }
    }


    private void exchangeJudgeDriverStyle(OrderPayStatus payStatus) {
        switch (payStatus) {
            case ORDER_FINISH:
                mJudgeInfoRl.setVisibility(View.VISIBLE);
                break;
            default:
                mJudgeInfoRl.setVisibility(View.GONE);
                break;
        }
    }

    private void exchangeBottomBarStyle(BizOrder bizOrder) {
        OrderPayStatus payStatus = bizOrder.getPayStatus();
        OrderRideStatus rideStatus = bizOrder.getRideStatus();
        switch (rideStatus) {
            case UN_SEND://未派车
                bottomContainerFrame.setVisibility(View.VISIBLE);
                mCancelOrderBarLl.setVisibility(View.VISIBLE);
                break;
            case UN_TAKEN://未上车
                bottomContainerFrame.setVisibility(View.VISIBLE);
                mCancelOrderBarLl.setVisibility(View.VISIBLE);
                break;
            case TAKEN://已上车
            case PART_TAKEN: //部分上车
                mCancelOrderBarLl.setVisibility(View.GONE);
                break;
            case ARRIVED://已到站
            case PART_ARRIVED: //部分已到站
                mCancelOrderBarLl.setVisibility(View.GONE);
                break;
            case RIDE_INVALID://未乘坐
            case DROP: //已放弃
                mCancelOrderBarLl.setVisibility(View.GONE);
                break;
            default:
        }
        switch (payStatus) {
            case CREATED:
                bottomContainerFrame.setVisibility(View.VISIBLE);
                break;
            default:
                bottomContainerFrame.setVisibility(View.GONE);
        }
    }

    private void exchangeTripMapStyle(OrderPayStatus payStatus) {
        switch (payStatus) {
            case CREATED:
            case PAID:
            case PART_FINISH:
            case OPS_PART_REFUND:
                mTripInfoMapIv.setClickable(true);
                mTripInfoMapIv.setImageResource(R.drawable.ic_kechakanditu);
                break;
            default:
                mTripInfoMapIv.setClickable(false);
                mTripInfoMapIv.setImageResource(R.drawable.ic_bukechakanditu);
                break;
        }
    }

    /**
     * 显示出发地
     *
     * @param station
     */
    private void setStartStation(String station) {
        if (!TextUtils.isEmpty(station)) {
            mStationInfoStartTv.setText(station);
        } else {
            mStationInfoStartTv.setText("");
        }
    }

    /**
     * 显示目的地
     *
     * @param station
     */
    private void setDestination(String station) {
        if (!TextUtils.isEmpty(station)) {
            mStationInfoDestinationTv.setText(station);
        } else {
            mStationInfoDestinationTv.setText("—— ——");
        }
    }

    /**
     * 显示出发时刻和日期
     *
     * @param timeStamp
     */
    private void setStartTimeAndData(String timeStamp) {
        if (!TextUtils.isEmpty(timeStamp)) {
            String[] strings = timeStamp.split(" ");
            mStationInfoDateTv.setText(strings[0]);
            mStationInfoClockTv.setText(strings[1]);
        } else {
            mStationInfoDateTv.setText("-");
            mStationInfoClockTv.setText("-");
        }
    }

    private void setTripFirstRowContent(String info) {
        if (!TextUtils.isEmpty(info)) {
            mFirstRowContentTv.setText(info);
        } else {
            //   mFirstRowContentTv.setText("—— ——");
            mFirstRowContentTv.setText("车辆调派中");
        }
    }

    private void setTripFirstRowContent(String info, OrderPayStatus payStatus) {
        if (!TextUtils.isEmpty(info)) {
            mFirstRowContentTv.setText(info);
        } else {
            //   mFirstRowContentTv.setText("—— ——");
            if (payStatus == PAY_CANCEL) {
                mFirstRowContentTv.setText("—— ——");
            } else {
                mFirstRowContentTv.setText("车辆调派中");
            }
        }
    }

    private void setTripSecondRowContent(String passengerMobile) {
        if (!TextUtils.isEmpty(passengerMobile)) {
            mSecondRowContentTv.setText(passengerMobile);
        }
    }

    /**
     * 显示订单编号
     *
     * @param orderId
     */
    private void setOrderId(String orderId) {
        if (!TextUtils.isEmpty(orderId)) {
            mOrderIdContentTv.setText(orderId);
        }
    }

    /**
     * 显示行程状态
     *
     * @param payStatus
     */
    private void setOrderStatus(OrderPayStatus payStatus) {
        String orderStatusStr;
        switch (payStatus) {
            case CREATED:
                orderStatusStr = getString(R.string.trip_detail_pay_status_created);
                break;
            case PAID:
                orderStatusStr = getString(R.string.trip_detail_pay_status_paid);
                break;
            case PAY_INVALID:
                orderStatusStr = getString(R.string.trip_detail_pay_status_invalid);
                break;
            case OPS_REFUNDING:
                orderStatusStr = getString(R.string.trip_detail_pay_status_refunding);
                break;
            case OPS_REFUND:
                orderStatusStr = getString(R.string.trip_detail_pay_status_refund);
                break;
            case PART_FINISH:
                orderStatusStr = getString(R.string.trip_detail_pay_status_part_finish);
                break;
            case ORDER_FINISH:
                orderStatusStr = getString(R.string.trip_detail_pay_status_finish);
                break;
            case PAY_CANCEL:
                orderStatusStr = getString(R.string.trip_detail_pay_status_cancel);
                break;
            case OPS_PART_REFUND:
                orderStatusStr = getString(R.string.trip_detail_pay_status_part_refunding);
                break;
//            case OPS_NO_REFUND:
//                orderStatusStr = "";
//                break;
            default:
                orderStatusStr = "";
        }
        mOrderStatusContentTv.setText(orderStatusStr);
    }

    /**
     * 显示行程状态
     *
     * @param payStatus
     */
    private void setOrderStatus(OrderPayStatus payStatus, OrderRideStatus rideStatus) {
        String orderStatusStr;
        switch (payStatus) {
            case CREATED:

                switch (rideStatus) {
                    case UN_SEND://未派车
                        orderStatusStr =  "等待接驾";
                        break;
                    case UN_TAKEN://未上车
                        orderStatusStr = mActivity.getString(R.string.route_detail_wait_charter);
                        break;
                    case TAKEN://已上车
                    case PART_TAKEN: { //部分上车

                        if (payStatus == OrderPayStatus.OPS_SEND_BILL) {
                            orderStatusStr = "等待支付";
                        } else {
                            orderStatusStr = mActivity.getString(R.string.route_detail_take_charter);
                        }
                        break;
                    }
                    case ARRIVED://已到站
                    case PART_ARRIVED: //部分已到站
                        if (payStatus == OrderPayStatus.PAID) {
                            orderStatusStr = "已支付";
                        } else {
                            orderStatusStr = mActivity.getString(R.string.route_detail_finish_charter);
                        }
                        break;
                    case RIDE_INVALID://未乘坐
                    case DROP: //已放弃
                        orderStatusStr = mActivity.getString(R.string.route_detail_cancel_charter);
                        break;
                    default:
                        orderStatusStr = "";
                }

                break;
            case PAID:
                orderStatusStr = getString(R.string.trip_detail_pay_status_paid);
                break;
            case PAY_INVALID:
                orderStatusStr = getString(R.string.trip_detail_pay_status_invalid);
                break;
            case OPS_REFUNDING:
                orderStatusStr = getString(R.string.trip_detail_pay_status_refunding);
                break;
            case OPS_REFUND:
                orderStatusStr = getString(R.string.trip_detail_pay_status_refund);
                break;
            case PART_FINISH:
                orderStatusStr = getString(R.string.trip_detail_pay_status_part_finish);
                break;
            case ORDER_FINISH:
                orderStatusStr = getString(R.string.trip_detail_pay_status_finish);
                break;
            case PAY_CANCEL:
                orderStatusStr = getString(R.string.trip_detail_pay_status_cancel);
                break;
            case OPS_PART_REFUND:
                orderStatusStr = getString(R.string.trip_detail_pay_status_part_refunding);
                break;
//            case OPS_NO_REFUND:
//                orderStatusStr = "";
//                break;
            default:
                orderStatusStr = "";
        }
        mOrderStatusContentTv.setText(orderStatusStr);
    }

    /**
     * 显示下单时间
     *
     * @param time
     */
    private void setGmtCreate(String time) {
        if (!TextUtils.isEmpty(time)) {
            mOrderCreateTimeContentTv.setText(time);
        }
    }

    /**
     * 上车时间
     */
    private void setGetInTime(String time, OrderRideStatus rideStatus, OrderPayStatus payStatus) {
        if (rideStatus == OrderRideStatus.UN_SEND || payStatus == PAY_CANCEL||rideStatus == OrderRideStatus.UN_TAKEN) {
            mGetInContentTv.setText("—— ——");
        } else {
            if (!TextUtils.isEmpty(time)) {
//                String[] strings = time.split(" ");
//                if (strings.length >= 2) {
                    mGetInContentTv.setText(time);
           //     }
            } else {
                mGetInContentTv.setText("—— ——");

            }
        }

    }

    /**
     * 上车时间
     */
    private void setGetInTime(String time) {
        if (!TextUtils.isEmpty(time)) {
            String[] strings = time.split(" ");
            if (strings.length >= 2) {
                mGetInContentTv.setText(strings[1]);
            }
        } else {
            mGetInContentTv.setText("—— ——");
        }
    }

    /**
     * 下车时间
     */
    private void setGetOffTime(String time) {
        if (!TextUtils.isEmpty(time)) {
            mGetOffContentTv.setText(time);
        } else {
            mGetOffContentTv.setText("—— ——");
        }
    }

    /**
     * 评价司机
     *
     * @param judgeEntry
     */
    private void setDriverJudge(JudgeEntry judgeEntry) {
        if (judgeEntry != null) {
            int judgePoint = judgeEntry.getJudgePoint();
            if (judgePoint > 0) {
                showJudePoint(judgePoint);
            } else {
                mJudgeCbl.setVisibility(View.INVISIBLE);
                mJudgeTv.setVisibility(View.VISIBLE);
            }
        } else {
            mJudgeCbl.setVisibility(View.INVISIBLE);
            mJudgeTv.setVisibility(View.VISIBLE);
        }
    }

    /**
     * 显示评价星星数
     *
     * @param judgePoint
     */
    private void showJudePoint(int judgePoint) {
        mJudgeCbl.setCheckedCount(judgePoint);
        mJudgeCbl.setClickable(false);
        mJudgeCbl.setVisibility(View.VISIBLE);
        mJudgeTv.setVisibility(View.INVISIBLE);
    }


    @Override
    public void renderDetailOrderOnSuccess(BizOrderResponse bizOrderResponse) {
        mBizOrder = bizOrderResponse.getOrderFieldses(0);
        initializeShow(mBizOrder);
        bindData(mBizOrder);
    }

    @Override
    public void renderDetailOrderOnFailure() {
        PromptUtils.showShort(getContext(), getString(R.string.net_error));
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (mMaterialDialog != null && mMaterialDialog.isShowing()) {
            mMaterialDialog.dismiss();
        }
    }

    @Override
    protected void initializeInjector() {
        DaggerTripComponent
                .builder()
                .appComponent(getAppComponent())
                .activityModule(new ActivityModule(mActivity))
                .tripModule(new TripModule())
                .build()
                .inject(this);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_official_car_detail;
    }

    @Override
    protected void setupToolBar() {
        ((TripDetailContainerActivity) mActivity).setToolbarTitle(R.string.trip_detail_header_title);
    }


}
